#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		char a[n+1][3];
		int f = 0;
		for (int i = 1; i <= 2; i++) {
		    for (int j = 1; j <= n; j++) {
				cin >> a[i][j];
			}
		}
			 for (int j = 1; j <= n; j++) {
			  if(a[1][j] == '1' && a[2][j] == '1') f = 1;
		  }
		if(f) puts("NO");
		else puts("YES");
	}
}
